package models

import (
	"time"

	"xorm.io/xorm"
)

type Product struct {
	Id             int64
	Name           string
	Price          float64
	Unit           string
	Cover          string
	Detail         string
	BusinessId     int64
	Sort           int64
	WriteOff       int64
	Status         int64
	WriteOffUserId string
	DeleteAt       time.Time `xorm:"deleted"`
}

func (p *Product) GetDivision(engine *xorm.Engine) (*ProductDivision, error) {
	division := &ProductDivision{ProductId: p.Id}

	_, err := engine.Get(division)
	if err != nil {
		return nil, err
	}
	return division, nil
}

type ProductDivision struct {
	Id                 int64
	ProductName        string
	ProductId          int64
	InviteAmount       float64
	InviteParentAmount float64
	BusinessAmount     float64
	DealerAmount       float64
	InviteAmountGive   int64
}
